package org.jeecg.modules.demo.znnqjc.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.demo.znnqjc.entity.ZwglZdfxfb;
import org.jeecg.modules.demo.znnqjc.entity.ZwglZhgjfb;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

/**
 * @Description: 种植格局附表
 * @Author: jeecg-boot
 * @Date:   2023-04-21
 * @Version: V1.0
 */
@Mapper
public interface ZwglZhgjfbMapper extends BaseMapper<ZwglZhgjfb> {

	/**
	 * 通过主表id删除子表数据
	 *
	 * @param mainId 主表id
	 * @return boolean
	 */
	public boolean deleteByMainId(@Param("mainId") String mainId);

   /**
    * 通过主表id查询子表数据
    *
    * @param mainId 主表id
    * @return List<ZwglZhgjfb>
    */
	public List<ZwglZhgjfb> selectByMainId(@Param("mainId") String mainId);


	@Select("SELECT\n" +
			"  wj,\n" +
			"  ROUND(SUM(ym), 2) AS sum_ym,\n" +
			"  ROUND(SUM(dd), 2) AS sum_dd,\n" +
			"  ROUND(SUM(sd), 2) AS sum_sd,\n" +
			"  ROUND(SUM(qt), 2) AS sum_qt\n" +
			"FROM\n" +
			"  zwgl_zhgjfb\n" +
			"GROUP BY\n" +
			"  wj;")
	List<Map<String, Object>> selectTotalSumGroupedByDj();

}
